from quiz.models import Quiz, Question
from django.contrib import admin


class QuestionInline(admin.TabularInline):
    fieldsets = [(None, {"fields": ["order", "parent", "text"]})]

    model = Question
    extra = 3


class QuizAdmin(admin.ModelAdmin):
    fieldsets = [
        (None,   {"fields" : ["title", "about", "final", "template"]}),
        ("Meta", {"fields" : ["creator", "created", "changed"], 
                  "classes": ["collapse"]}),
        ]
    inlines = [QuestionInline]
    list_display = ("title", "creator", "final", "remaining")
    list_filter = ["final"]
    search_fields = ["title", "about"]
    date_hierarchy = "final"


admin.site.register(Quiz, QuizAdmin)
